package com.bizmerce.rnd.oms.decision.criterion;

import java.util.List;

import com.bizmerce.rnd.oms.decision.data.BillOfMaterials;
import com.bizmerce.rnd.oms.decision.data.RawMaterial;

/**
 * 대상협정: 한-아세안 FTA, 한-미 FTA
 * 직접법: Build-up Method
 * @param vom Value of Originating Material
 * @param value FOB 또는 AV(Adjusted Value)
 */
//중간재 규정 적용 

//상품가격 (구분)
//원재료 합계 가격
//원산지 재료비
//비원산지 재료비
public class BuildUpMethod extends LocalContents {

	//return Math.floor(vom / value * 100);
	public Boolean assign(BillOfMaterials bom) {
		double fobValue = bom.getSalePrice();
		double vomValue = 0.;
		List<RawMaterial> materials = bom.getRawMaterials();
		for (RawMaterial rawMaterial : materials) {
			if(rawMaterial.isIntraItem()) {
				vomValue +=  rawMaterial.getPurchasePrice();
			}
		}	
		boolean result = false;
		double value = Math.floor(vomValue / fobValue * 100);
		System.out.println("BU:" + value + "%");
		result = (value >= 45); //45%
		return result;
	}

}
